import java.util.Arrays;

/**
 * 出现最频繁的偶数
 *
 * @USER: Administrator
 * @DATE: 2024/9/29 上午12:43
 * @VERSION: 1.0.0
 */
public class LC2404 {
    public static void main(String[] args) {

    }

    public int mostFrequentEven(int[] nums) {
        Arrays.sort(nums);
        int maxCount = -1;
        int cur = -1;
        int count = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] % 2 == 0) {
                if (i>0&&nums[i]==nums[i-1]) {
                    count++;
                }else {
                    count=1;
                }
                if (count>maxCount) {
                    maxCount = count;
                    cur = nums[i];
                }
            }
        }
        return cur;
    }

}
